SDCC		= sdcc
CP		= cp
RM		= rm -f

CFLAGS		=--code-loc 0x2000 --data-loc 0x30  --xram-loc 0x6000 -I./ -I./utils -I./lcd
LDFLAGS		= --code-loc 0x2000 --data-loc 0x30  --xram-loc 0x6000 

LDFLAGS		+= -L /usr/share/sdcc/lib/small/

COBJECTS	= mainlcd.rel utils/msclibs.rel lcd/Lcd.rel 
CSOURCES	= $(patsubst %.rel,%.c,$(COBJECTS))

.SUFFIXES:	.rel

.c.rel:
		$(SDCC) -o $@ $(CFLAGS) -c $<

all: usbirboy
	$(SDCC) $(LDFLAGS) $(COBJECTS)
	packihx mainlcd.ihx > mainlcd.hex

c:		$(COBJECTS)

usbirboy:	$(COBJECTS)

.PHONY : clean
clean:	
	$(RM) $(COBJECTS)
include Makefile.dep

dep:	Makefile.dep

Makefile.dep:	$(CSOURCES)
	$(RM) Makefile.dep
	for csrc in $(CSOURCES); do \
	  $(SDCC) -MM $$csrc >> Makefile.dep ; \
	done